<%@page import="Modelo.Querys"%>
<%@page import="Controlador.ConnectionDB"%>
<%@page pageEncoding="UTF-8" %>
<% 
String TypeMessage = "info";
String FinalMessage = "Acción creado exitosamente!";
String ActionCode = Querys.DecodeString(request.getParameter("ActionCode"));
String ActionName = Querys.DecodeString(request.getParameter("ActionName"));
String ActionDescription = Querys.DecodeString(request.getParameter("ActionDescription"));
String Incident = request.getParameter("SelectPlugin");
String TypeAlert = request.getParameter("SelectAlert");
ConnectionDB c = new ConnectionDB();
if(c.Connect()){
    int r = c.getUpdate("insert into Action (Code, Name, Description, Plugin) values ('"+ActionCode+"','"+ActionName+"','"+ActionDescription+"', "+Incident+");");    
    if(r>0){
        c.commit(true);
    }else{
        FinalMessage = "No se pudo ingresar, Verifique si ya existe la Acción.";
        TypeMessage = "error";
    }
    c.close();
}else{
    FinalMessage = "No se pudo conectar a la base de datos.";
    TypeMessage = "error";
}
%>
<jsp:forward page="create_agent.jsp">
    <jsp:param name="FinalMessage" value="<%=FinalMessage%>" />       
    <jsp:param name="TypeMessage" value="<%=TypeMessage%>"/>
</jsp:forward>